package com.javaeedev.junit;

public class ReadingThread extends Thread {

    private Cache cache;

    public ReadingThread(Cache cache) {
        this.cache = cache;
    }

    public void run() {
        for(int i=0; i<1000; i++) {
            char[] cs = cache.read();
            if(!check(cs))
                System.out.println("FAILED: " + new String(cs));
        }
    }

    private boolean check(char[] cs) {
        char c = cs[0];
        for(int i=1; i<cs.length; i++) {
            if(c!=cs[i])
                return false;
        }
        return true;
    }
}
